// pages/waiter/ordercheckHis/ordercheckHis.js
const request = require('@/utils/request.js')
const constants = require('@/utils/khyConstants.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList: [],
    pageNo: 1,
    pageSize: constants.pageSize,
    total: 0,
    transportStateList: getApp().globalData.dictData['transportState'],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const app = getApp();
    this.setData({
      daofu:app.globalData.nginxIp+'/img/daofu.png',
    })
    this.getPageData(1)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
  },

  getPageData(pageNo) {
    let user = getApp().getUserInfo()
    let dataCenter = {
      pageNo: pageNo,
      pageSize: this.data.pageSize,
      queryForm: [
        {field: 'tallyClerkShou', val: user.userNo}
      ]
    }
    
    request.post('/UserController/getTransInfoByTallyClerkShou', dataCenter).then(res => {
      if (res.data.code == constants.resultSuccessCode
        && res.data.result) {
        let data = res.data.result.records || []
        let total = res.data.result.total || 0
        data = this.data.dataList.concat(data)
        this.setData({
          dataList: data,
          total: total
        })
      }
    })
  },

  //运输单详情
  delivery(e) {
    let transinfo = e.currentTarget.dataset.transinfo
    if (transinfo) {
      getApp().globalData.pageData[constants.page_transferOrder] = transinfo
      wx.navigateTo({
        url: '/pages/transferOrder/transferOrder',
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    let pageNo = this.data.pageNo;
    let total = this.data.total
    let pageNum = total % this.data.pageSize > 0 ? parseInt(total / this.data.pageSize) + 1 : parseInt(total / this.data.pageSize)
    if (pageNo < pageNum) {
      pageNo = pageNo + 1
      this.getPageData(pageNo)
      this.setData({
        pageNo: pageNo
      })
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})